print("======dict====")
# 定义
my_dict = {}
my_dict = dict()
my_dict = {"a": "132465", "b": 80, "c": 85}
print(my_dict)

# 新增
my_dict["d"] = 60
print(my_dict)
# 修改
my_dict["d"] = 65
print(my_dict)
# pop 去除并且删除
pop = my_dict.pop("d")
print(pop)
print(my_dict)
# len
print(len(my_dict))
# 获取全部key
keys = my_dict.keys()
print(type(keys))
print(keys)
# 遍历方式一：
for key in keys:
    print(f"{key}的值是{my_dict[key]}")
# 遍历方式二：
for key in my_dict:
    print(f"{key}的值是{my_dict[key]}")
# clear
my_dict.clear()
print(my_dict)

# 练习
my_dict = {
    "a": {"age": 18, "type": 1},
    "b": {"age": 19, "type": 2},
    "c": {"age": 20, "type": 2},
    "d": {"age": 21, "type": 2},
}
print(my_dict)

for key in my_dict:
    if my_dict[key]["type"]==1:
        print(my_dict[key])
        #my_value= my_dict[key]
        #my_value["age"]=99
        my_dict[key]["age"]=100
        print(my_dict[key])

print(my_dict)